<?php
namespace app\restaurant\controller;
use app\AdminRest;

use app\dynamic\model\CardUser;
use app\dynamic\model\UserInfo;
use app\restaurant\info\PermissionRestaurant;
use app\restaurant\model\ClassConnect;
use app\restaurant\model\ClassDate;
use app\restaurant\model\Config;
use app\restaurant\model\Delivery;
use app\restaurant\model\Evaluate;
use app\restaurant\model\ResClass;
use app\restaurant\model\StoreStaff;
use app\restaurant\model\Table;
use longbingcore\wxcore\Excel;
use think\App;

use app\restaurant\model\Store as model;

use app\restaurant\model\Order;

use app\restaurant\model\RefundOrder;

use app\restaurant\model\StoreConfig;

use think\facade\Db;


class AdminStore extends AdminRest
{

    protected $model;

    protected $staff_model;

    protected $order_model;

    protected $refund_model;

    protected $store_config_model;

    protected $config_model;

    protected $delivery_model;

    public function __construct(App $app) {

        parent::__construct($app);

        $this->model = new Model();

        $this->staff_model = new StoreStaff();

        $this->order_model = new Order();

        $this->refund_model = new RefundOrder();

        $this->store_config_model = new StoreConfig();

        $this->config_model = new Config();

        $this->delivery_model = new Delivery();

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:35
     * @功能说明:列表
     */
    public function storeList(){

        $input = $this->_param;

        $dis[] = ['status','>',-1];

        $dis[] = ['uniacid','=',$this->_uniacid];

        if(!empty($input['title'])){

            $dis[] = ['title','like','%'.$input['title'].'%'];
        }

        $data = $this->model->storeList($dis,$input['limit']);

        return $this->success($data);

    }





    /**
     * @author chenniang
     * @DataTime: 2020-10-09 11:01
     * @功能说明:添加门店
     */
    public function storeAdd(){

        $input = $this->_input;

        $input['uniacid'] = $this->_uniacid;

        $p = new PermissionRestaurant($this->_uniacid);

        $auth_num = $p->getStoreNumber();

        $have_num = $this->model->where(['uniacid'=>$this->_uniacid])->where('status','>',-1)->count();

        if($have_num>=$auth_num){

            $this->errorMsg('门店限制数量'.$auth_num);
        }

        $res = $this->model->storeAdd($input);

        return $this->success($res);


    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 13:28
     * @功能说明:详情
     */
    public function storeInfo(){

        $input = $this->_param;

        $dis = [

            'id' => $input['id']
        ];

        $data = $this->model->storeInfo($dis);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 13:29
     * @功能说明:编辑
     */
    public function storeUpdate(){

        $input = $this->_input;

        $dis = [

            'id' => $input['id'],

            'uniacid' => $this->_uniacid
        ];

        $data = $this->model->storeUpdate($dis,$input);

        return $this->success($data);

    }



    /**
     * @author chenniang
     * @DataTime: 2020-09-29 13:29
     * @功能说明:编辑
     */
    public function storeUpdateBatch(){

        $input = $this->_input;

        foreach ($input['id'] as $value){

            $dis = [

                'id' => $value
            ];

            if($input['status']==-1){

                $this->staff_model->where(['store_id'=>$value])->delete();
            }

            $data = $this->model->where($dis)->update(['status'=>$input['status']]);
        }

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-10-10 15:44
     * @功能说明:门店下拉框
     */
    public function storeSelect(){

        $dis = [

            'uniacid' => $this->_uniacid,

            'status'  => 1
        ];

        $data = $this->model->where($dis)->field('id,title')->order('top')->select()->toArray();

        return $this->success($data);


    }


    /**
     * @author chenniang
     * @DataTime: 2020-10-12 09:42
     * @功能说明:员工下拉框
     */
    public function staffSelect(){

        $input = $this->_input;

        $user_model = new UserInfo();

        $user_info  = new CardUser();

        $staff_model= new StoreStaff();

        $where[] = ['a.uniacid','=',$this->_uniacid];

        $where[] = ['b.status','>',-1];

        if(!empty($input['id'])){

           // $where[] = ['a.store_id','<>',$input['id']];
        }

        $have  = $staff_model->alias('a')
                ->join('longbing_card_restaurant_store b','a.store_id = b.id')
                ->where($where)
                ->column('a.staff_id');

        $dis[] = ['is_staff','=',1];

        $dis[] = ['uniacid','=',$this->_uniacid];

        $data = $user_model->where($dis)->field('fans_id as id,name')->select();

        if(!empty($data)){

            foreach ($data as &$v){

                $v['status'] = in_array($v['id'],$have)?0:1;

                if(empty($v['name'])){

                    $v['name'] = $user_info->where(['id'=>$v['id']])->value('nickName');
                }
            }
        }
        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-10-12 10:47
     * @功能说明:
     */
    public function storeStaffAdd(){

        $input = $this->_input;

        $res = $this->staff_model->dataAdd($input,$this->_uniacid);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-10-12 11:27
     * @功能说明:修改店员
     */
    public function storeStaffUpdate(){

        $input = $this->_input;

        $res   = $this->staff_model->staffUpdate(['id'=>$input['id']],$input);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-10-12 11:46
     * @功能说明:店员列表
     */
    public function storeStaffList(){

        $input = $this->_input;

        $dis[] = ['a.uniacid','=',$this->_uniacid];

        $dis[] = ['a.store_id','=',$input['store_id']];

        $where = [];

        if(!empty($input['name'])){

            $where[] = ['b.name','like','%'.$input['name'].'%'];

            $where[] = ['b.phone','like','%'.$input['name'].'%'];
        }

        $data = $this->staff_model->staffList($dis,$where,$input['limit'],$this->_uniacid);

        return $this->success($data);



    }

    /**
     * @author chenniang
     * @DataTime: 2020-10-12 11:32
     * @功能说明:设置或者取消管理员
     */
    public function setRole(){

        $input = $this->_input;

        $this->staff_model->staffUpdate(['store_id'=>$input['store_id'],'role'=>1],['role'=>0]);

        $res = $this->staff_model->staffUpdate(['store_id'=>$input['store_id'],'staff_id'=>$input['staff_id']],['role'=>1]);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-10-12 11:56
     * @功能说明:店员删除
     */
    public function storeStaffDel(){

        $input = $this->_input;

        $data  = $this->staff_model->where(['id'=>$input['id']])->find();

        if(!empty($data)&&$data['role']==1){

            $this->errorMsg('管理员不能直接删除,请先指派新的管理员');
        }

        $res = $this->staff_model->staffDel(['id'=>$input['id']]);

        return $this->success($res);

    }



    /**
     * @author chenniang
     * @DataTime: 2020-10-13 09:46
     * @功能说明:门店统计
     */

    public function storeFrom(){

        reupdateDataDay($this->_uniacid);

        $input = $this->_input;

        $toDay = date('Y-m-d',time());
        //今天
        $data['today_from'] = $this->order_model->storeOrderFrom($input['store_id'],$toDay,$this->_uniacid);

        $yesterday = date('Y-m-d',time()-86400);
        //昨天
        $data['yesterday_from'] = $this->order_model->storeOrderFrom($input['store_id'],$yesterday,$this->_uniacid);

        $day_num = $this->order_model->diffBetweenTwoDays($input['end_time'],$input['start_time']);
        //图表统计
        for ($i=0;$i<$day_num;$i++){

            $day = date('Y-m-d',$input['start_time']+86400*$i);

            $from[$i] = $this->order_model->storeOrderFrom($input['store_id'],$day,$this->_uniacid);

            $from[$i]['date'] = date('m-d',$input['start_time']+86400*$i);
        }

        $data['from'] = array_values($from);

        if(!empty($input['list_start_time'])&&!empty($input['list_end_time'])){

            $list_start_time = $input['list_start_time'];

            $list_end_time   = $input['list_end_time'];

            $list_where[] = ['time','between',"$list_start_time,$list_end_time"];
        }

        $list_where[] = ['uniacid','=',$this->_uniacid];
        //每日详情
        $from_list = Db::name('longbing_card_restaurant_date')->where($list_where)->order('id desc')->paginate($input['limit'])->toArray();

        foreach ($from_list['data'] as &$v){

            $v['list'] = $this->order_model->storeOrderFrom($input['store_id'],$v['date'],$this->_uniacid);

        }
        $data['list'] = $from_list;
        //会员订单
        $data['member_type'] = $this->order_model->memberOder($input['store_id'],$this->_uniacid);
        //订单类型
        $data['order_type']  = $this->order_model->fromOrder($input['store_id'],$this->_uniacid);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-10-13 17:38
     * @功能说明:数据概览
     */
    public function fromList(){

        $input = $this->_input;

        $toDay = date('Y-m-d',time());
        //今天
        $data['today_from'] = $this->order_model->storeOrderFrom('',$toDay,$this->_uniacid);

        $yesterday = date('Y-m-d',time()-86400);
        //昨天
        $data['yesterday_from'] = $this->order_model->storeOrderFrom('',$yesterday,$this->_uniacid);
        //所有
        $data['all_from']   = $this->order_model->storeOrderFrom('','',$this->_uniacid);
        //门店排行榜
        $data['store_list'] = $this->model->storeTop($this->_uniacid,$input['limit']);

        if(!empty($data['store_list']['data'])){

            foreach ($data['store_list']['data'] as $k=>&$v){

                $list = $this->order_model->storeOrderFrom($v['id'],$toDay,$this->_uniacid);

                $v    = array_merge($v,$list);

                $v['total_price'] = $this->order_model->storeOderCount($v['id'],'',$this->_uniacid,2);

            }
        }

        return $this->success($data);
    }


    /**
     * @author chenniang
     * @DataTime: 2020-10-14 10:11
     * @功能说明:门店排行
     */
    public function storeTop(){

        $input = $this->_input;

        $title = !empty($input['title'])?$input['title']:'';

        $toDay = date('Y-m-d',time());
        //门店排行榜
        $data = $this->model->storeTop($this->_uniacid,$input['limit'],$title);

        if(!empty($data['data'])){

            foreach ($data['data'] as $k=>&$v){

                $list = $this->order_model->storeOrderFrom($v['id'],$toDay,$this->_uniacid);

                $v    = array_merge($v,$list);

                $v['total_price'] = $this->order_model->storeOderCount($v['id'],'',$this->_uniacid,2);

            }
        }

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-11-10 10:49
     * @功能说明:门店配置信息
     */
    public function storeConfig(){

        $input = $this->_input;

        $info  = $this->store_config_model->configInfo(['store_id'=>$input['store_id'],'uniacid'=>$this->_uniacid]);

        $config= $this->config_model->configInfo(['uniacid'=>$this->_uniacid]);

        $info['setting_send']  =

            [
                'dada_send'   => $config['dada_send'],

                'store_send'  => $config['store_send'],

                'meituan_send'=> $config['meituan_send']

            ];

        return $this->success($info);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-11-10 13:46
     * @功能说明:编辑门店配置信息
     */
    public function storeConfigUpdate(){

        $input = $this->_input;

        $res   = $this->store_config_model->configUpdate(['uniacid'=>$this->_uniacid],$input);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-11-10 17:58
     * @功能说明:商家配送费列表
     */
    public function deliveryList(){

        $input = $this->_input;

        $dis[] = ['store_id','=',$input['store_id']];

        $dis[] = ['status','>',-1];

        $data = $this->delivery_model->configList($dis,$input['limit']);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-11-10 18:03
     * @功能说明:添加商家配送费
     */
    public function deliveryAdd(){

        $input = $this->_input;

        $input['uniacid'] = $this->_uniacid;

        if(isset($input['status'])&&$input['status']==1){

            $this->delivery_model->configUpdate(['store_id'=>$input['store_id'],'status'=>1],['status'=>0]);
        }

        $res = $this->delivery_model->configAdd($input);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-11-10 18:03
     * @功能说明:添加商家配送费
     */
    public function deliveryUpdate(){

        $input = $this->_input;

        if(isset($input['status'])&&$input['status']==1){

            $this->delivery_model->configUpdate(['store_id'=>$input['store_id'],'status'=>1],['status'=>0]);
        }

        $res   = $this->delivery_model->configUpdate(['id'=>$input['id']],$input);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-02-22 10:30
     * @功能说明:增加桌号
     */
    public function tableAdd(){

        $input = $this->_input;

        $input['uniacid'] = $this->_uniacid;

        $table_model = new Table();

        $res = $table_model->dataAdd($input);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-03-01 18:11
     * @功能说明:修改桌号码
     */
    public function tableQr(){

        $input  = $this->_input;

        $tab_id = $input['table_id'];

        $table_model = new Table();

        $input['key']= 41;

        $input['type']= 23;

        $data   = longbingCreateWxCode($this->_uniacid,$input,'pages/user/home');

        $qr    = '';

        if(isset($data['qr_path'])){

            $data = transImagesOne($data ,['qr_path'] ,$this->_uniacid);

            $res  = $table_model->dataUpdate(['id'=>$tab_id],['qr'=>$data['qr_path']]);

            $qr   = $data['qr_path'];

        }

        return $this->success($qr);

    }



    /**
     * @author chenniang
     * @DataTime: 2021-02-22 10:31
     * @功能说明:桌号列表
     */
    public function tableList(){

        $input = $this->_input;

        $dis[] = ['store_id','=',$input['store_id']];

        $dis[] = ['status','>',-1];

        if(!empty($input['title'])){

            $dis[] = ['title','like','%'.$input['title'].'%'];

        }

        $table_model = new Table();

        $data = $table_model->dataList($dis,$input['limit']);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-02-22 10:33
     * @功能说明:桌号详情
     */
    public function tableInfo(){

        $input = $this->_input;

        $dis = [

            'id' => $input['id']
        ];

        $table_model = new Table();

        $data = $table_model->dataInfo($dis);

        return $this->success($data);
    }


    /**
     * @author chenniang
     * @DataTime: 2021-02-22 10:35
     * @功能说明:桌号编辑
     */
    public function tableUpdate(){

        $input = $this->_input;

        $dis = [

            'id' => $input['id']
        ];

        $table_model = new Table();

        $data = $table_model->dataUpdate($dis,$input);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-02-26 09:29
     * @功能说明:班次列表
     */
    public function classList(){

        $input = $this->_input;

        $dis = [

            'uniacid' => $this->_uniacid,

            'store_id'=> $input['store_id']
        ];

        $class_model = new ResClass();

        $class_model->initreset($dis);

        $res = $class_model->dataList($dis,$input['limit']);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-02-26 09:29
     * @功能说明:添加班次
     */
    public function classAdd(){

        $input = $this->_input;

        $input['uniacid'] = $this->_uniacid;

        $class_model = new ResClass();

        $check = $class_model->checkClass($input);

        if(!empty($check['code'])){

            $this->errorMsg($check['msg']);
        }

        $res = $class_model->dataAdd($input);

        return $this->success($res);

    }

    /**
     * @author chenniang
     * @DataTime: 2021-02-22 10:58
     * @功能说明:排班详情
     */
    public function classInfo(){

        $input = $this->_input;

        $dis = [

            'uniacid' => $this->_uniacid,

            'store_id'=> $input['store_id']
        ];

        $class_model = new ResClass();

        $res = $class_model->dataInfo($dis);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-02-22 11:01
     * @功能说明:编辑排班
     */
    public function classUpdate(){

        $input = $this->_input;

        $class_model = new ResClass();

        $input['uniacid'] = $this->_uniacid;

        $check = $class_model->checkClass($input);

        if(!empty($check['code'])){

            $this->errorMsg($check['msg']);
        }

        $dis = [

            'id'=> $input['id']
        ];

        $class = $class_model->dataInfo($dis);

        $dis['store_id'] = $class['store_id'];

        $res = $class_model->updateConnect($dis,$input);

        return $this->success($res);
    }


    /**
     * @author chenniang
     * @DataTime: 2021-02-26 14:36
     * @功能说明:返回班次时间的表头
     */
    public function getDataTitle(){

        $input = $this->_param;

        $class_model = new ResClass();

        $data = $class_model->getDataTitle($input['day']);

        return $this->success($data);

    }

    /**
     * @author chenniang
     * @DataTime: 2021-02-26 14:24
     * @功能说明:门店管理员排班列表
     */
    public function classDataList(){

        $input = $this->_param;

        $dis[] = ['a.uniacid','=',$this->_uniacid];

        $dis[] = ['a.store_id','=',$input['store_id']];

        $dis[] = ['b.is_staff','=',1];

        if(!empty($input['title'])){

            $dis[] = ['b.name','like','%'.$input['title'].'%'];

        }
        //获取员工
        $data = $this->staff_model->staffList($dis,[],$input['limit'],$this->_uniacid);

        $class_model = new ResClass();

        $date_model  = new ClassDate();
        //获取时间
        $date = $class_model->getDataTitle($input['day']);

        if(!empty($data['data'])){

            foreach ($data['data'] as $k=>&$v){

                foreach ($date as $vs){

                    $where = [

                        'uniacid' => $this->_uniacid,

                        'date'    => $vs['time_str'],

                        'staff_id'=> $v['staff_id'],

                        'store_id'=> $input['store_id']

                    ];
                    //查询排班情况
                    $vs['class_title'] = $date_model->where($where)->value('class_title');

                    $vs['class_id'] = $date_model->where($where)->value('class_id');

                    $v[$vs['day']] = $vs;


                }

            }

        }

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-02-27 10:49
     * @功能说明:员工每天的排班情况
     */
    public function classDataInfo(){

        $input = $this->_param;

        $date_model    = new ClassDate();

        $connect_model = new ClassConnect();

        $where = [

            'uniacid' => $this->_uniacid,

            'date'    => $input['time'],

            'staff_id'=> $input['staff_id'],

            'store_id'=> $input['store_id']

        ];
        //查询排班情况
        $data = $date_model->dataInfo($where);

        if(!empty($data)){
            //桌子绑定情况
            $data['table'] = $connect_model->where(['date_id'=>$data['id']])->column('table_id');

            $data['table'] = array_values($data['table']);
        }

        return $this->success($data);
    }


    /**
     * @author chenniang
     * @DataTime: 2021-02-27 11:02
     * @功能说明:编辑员工每一天的排班情况
     */
    public function updateClassData(){

        $input = $this->_param;

        $date_model = new ClassDate();

        $res = $date_model->updateClassData($input,$this->_uniacid);

        if(!empty($res['code'])){

            $this->errorMsg($res['msg']);
        }

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-03-01 10:11
     * @功能说明:桌号下拉框
     */
    public function tableSelect(){

        $input = $this->_param;

        $dis[] = ['uniacid','=',$this->_uniacid];

        $dis[] = ['status','>',-1];

        $dis[] = ['store_id','=',$input['store_id']];

        $date_model = new Table();

        $data = $date_model->where($dis)->select()->toArray();

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-03-01 10:41
     * @功能说明:班次下拉
     */
    public function classSelect(){

        $input = $this->_param;

        $dis[] = ['uniacid','=',$this->_uniacid];

        $dis[] = ['status','>',-1];

        $dis[] = ['store_id','=',$input['store_id']];

        $date_model = new ResClass();

        $data = $date_model->where($dis)->select()->toArray();

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-03-03 09:30
     * @功能说明:后台评价列表
     */
    public function evaluateList(){

        $input = $this->_param;

        $dis[] = ['a.uniacid','=',$this->_uniacid];

        $dis[] = ['a.store_id','=',$input['store_id']];

        $dis[] = ['a.status','>',-1];

        if(!empty($input['type'])){

            if($input['type']==1){

                $dis[] = ['a.star','>',2];

            }else{

                $dis[] = ['a.star','<',3];
            }

        }

        $evaluate_model = new Evaluate();

        $data = $evaluate_model->adminList($dis,$input['limit']);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-03-03 09:33
     * @功能说明:详情
     */
    public function evaluateInfo(){

        $input = $this->_param;

        $dis[] = ['a.id','=',$input['id']];

        $evaluate_model = new Evaluate();

        $data = $evaluate_model->adminInfo($dis);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-03-03 09:34
     * @功能说明:获取好评差评数量
     */
    public function evaluateCount(){

        $input = $this->_param;

        $dis[] = ['uniacid','=',$this->_uniacid];

        $dis[] = ['store_id','=',$input['store_id']];

        $dis[] = ['status','>',-1];

        $evaluate_model = new Evaluate();
        //好评数量
        $data['goods_evaluate'] = $evaluate_model->where($dis)->where('star','>',2)->count();
        //差评数量
        $data['bad_evaluate']   = $evaluate_model->where($dis)->where('star','<=',2)->count();

        $data['all_evaluate']   = $evaluate_model->where($dis)->count();

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-03-03 09:41
     * @功能说明:修改评价
     */
    public function evaluateUpdate(){

        $input = $this->_input;

        $evaluate_model = new Evaluate();

        $dis = [

            'id' => $input['id']
        ];

        $res = $evaluate_model->dataUpdate($dis,$input);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-02-26 14:24
     * @功能说明:门店管理员排班列表导出
     */
    public function classDataListExcel(){

        $input = $this->_param;

        $dis[] = ['a.uniacid','=',$this->_uniacid];

        $dis[] = ['a.store_id','=',$input['store_id']];

        $dis[] = ['b.is_staff','=',1];

        if(!empty($input['title'])){

            $dis[] = ['b.name','like','%'.$input['title'].'%'];

        }
        if(!empty($input['id'])){

            $dis[] = ['a.id','in',$input['id']];
        }
        //获取员工
        $data = $this->staff_model->staffList($dis,[],10000,$this->_uniacid);

        $class_model = new ResClass();

        $date_model  = new ClassDate();
        //获取时间
        $date = $class_model->getDataTitle($input['day']);
        //标题
        $header = array_column($date,'time');

        array_unshift($header,'员工');

        if(!empty($data['data'])){

            foreach ($data['data'] as $k=>&$v){

                foreach ($date as $vs){

                    $where = [

                        'uniacid' => $this->_uniacid,

                        'date'    => $vs['time_str'],

                        'staff_id'=> $v['staff_id'],

                        'store_id'=> $input['store_id']

                    ];
                    //查询排班情况
                    $vs['class_title'] = $date_model->where($where)->value('class_title');

                    $v[$vs['day']] = $vs;

                }

            }

        }

        $new_data = [];

        foreach ($data['data'] as &$v){

            $info   = array();

            $info[] = $v['staff_name'];

            for ($i=1;$i<=31;$i++){

                $info[] = !empty($v[$i]['class_title'])?$v[$i]['class_title']:'--';
            }

            $new_data[] = $info;
        }

        $store_name = $this->model->where(['id'=>$input['store_id']])->value('title');

        $date = date('Y-m-d',$input['day']);
        //
        $name  =$store_name.'~'.$date;

        $excel_model = new Excel();
        //返回数据
        $fileName = $excel_model->excelExport($name,$header,$new_data);

        return $this->success($fileName);

    }




}
